package cc.lucien.web.service.serviceImpl;

import cc.lucien.web.dao.AdminMapper;
import cc.lucien.web.entity.Admin;
import cc.lucien.web.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin getAdminByUsernameAndPassword(String username, String password) {
        Map<String, Object> param = new HashMap<>();
        param.put("username", username);
        param.put("password", password);
        return adminMapper.getAdminByUsernameAndPassword(param);
    }

    @Override
    public List<Admin> selectAllAdmins() {
        return adminMapper.selectAllAdmins();
    }

    @Override
    public int adminSave(Admin admin) {
        return adminMapper.insert(admin);
    }

    @Override
    public int deleteAdmin(Integer id) {
        return adminMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Admin selectAdminById(Integer id) {
        return adminMapper.selectByPrimaryKey(id);
    }

    @Override
    public int adminUpdate(Admin admin) {
        return adminMapper.updateByPrimaryKey(admin);
    }
}
